home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / GL / logo / light.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.0 KB  |  95 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *  light.c
  19.  */
  20.  
  21. #include "gl.h"
  22. #include "light.h"
  23.  
  24. static int curmaterial = 0;
  25.  
  26. /*
  27.  *  materials
  28.  */
  29. float mat_logo[] = {AMBIENT,    0.0, 0.0, 0.0,
  30.             DIFFUSE,    0.8, 0.4, 1.0,
  31.             SPECULAR,    1.0, 1.0, 1.0,
  32.             SHININESS,    20.0,
  33.             LMNULL};
  34.  
  35.  
  36. /*
  37.  *  lights
  38.  */
  39. float light1[] = {AMBIENT, 0.0, 0.0, 0.0, 
  40.            LCOLOR,   1.0, 1.0, 1.0, 
  41.            POSITION, 1.0, 0.0, 0.0, 0.0, 
  42.            LMNULL};
  43.  
  44. float light2[] = {AMBIENT, 0.0, 0.0, 0.0, 
  45.            LCOLOR,   0.5, 0.1, 0.0, 
  46.            POSITION, 0.0, -1.0, 0.0, 0.0, 
  47.            LMNULL};
  48.  
  49. /*
  50.  *  lighting models
  51.  */
  52. float infinite[] = {AMBIENT, 0.3,  0.3, 0.3, 
  53.                 LOCALVIEWER, 0.0, 
  54.                 LMNULL};
  55.  
  56.  
  57. init_lighting()
  58. {
  59.     lmdef (DEFMATERIAL, MAT_LOGO, 0, mat_logo);
  60.  
  61.     lmdef (DEFLIGHT, OVER_LIGHT, 0, light1);
  62.     lmdef (DEFLIGHT, UNDER_LIGHT, 0, light2);
  63.  
  64.     lmdef (DEFLMODEL, INFINITE, 0, infinite);
  65.  
  66.     lmbind(LIGHT0, OVER_LIGHT); 
  67.     lmbind(LIGHT1, UNDER_LIGHT);
  68.  
  69.     /*
  70.      *  load the lighting model and then turn off lighting
  71.      */
  72.     lmbind(LMODEL, INFINITE);
  73.     lmbind(LMODEL, 0);
  74. }
  75.  
  76.  
  77. lighting(b)
  78.     int b;
  79. {
  80.     if (b)
  81.     lmbind(LMODEL, INFINITE);
  82.     else
  83.     lmbind(LMODEL, 0);
  84. }
  85.  
  86.  
  87. setmaterial(name)
  88. {
  89.     if (name != curmaterial)
  90.     {
  91.     curmaterial = name;
  92.     lmbind(MATERIAL, name);
  93.     }
  94. }
  95.